<?=form_open_multipart(uri_string(),array('id'=>'product'))?>
<table class="form">
    <tr>
        <td class="label required" style="width: 150px;"><?=lang('category_name')?></td>
        <td><select id="catid" name="catid" class="w350">
                <option value=""><?=lang('select_category')?></option>
                <?php echo $category_option ?>
            </select></td>
    </tr>
    <tr>
        <td class="required label" style="width: 150px;"><?=lang('title_vn')?></td>
        <td><input type="text" name="name_vn" id="name_vn" class="w710" value="<?=$rs->name_vn?>"></td>
    </tr>
    <tr>
        <td class="label" style="width: 150px;"><?=lang('title_en')?></td>
        <td><input type="text" name="name_en" id="name_en" class="w710" value="<?=$rs->name_en?>"></td>
    </tr>
    <tr>
        <td class="label" style="width: 150px;">Ảnh đại diện</td>
        <td><a class="lib_img" href="javascript:imgLib.openLib({width:175,height:175,return_tag:'lb_image',action:'imgcrop'});"></a>
            <div class="lb_image">
                <input type="hidden" name="lb_image" value="" id="lb_image">
                <? if(!empty($rs->lb_image)){?>
                <a href="javascript:imgLib.openLib({dir_img:'product/<?=$rs->lb_image?>',width:175,height:175,method:'imgcrop',return_tag:'lb_image',action:'imgcrop'});"><img src="<?=base_url_site()?>uploads/product/<?=$rs->lb_image?>" width="95px" /> </a>
                <? } ?>
            </div></td>
    </tr>
    <tr>
        <td class="label" style="width: 150px;">Banner sản phẩm</td>
        <td><a class="lib_img" href="javascript:imgLib.openLib({width:756,height:180,return_tag:'pro_banner',action:'imgcrop'});"></a>
            <div class="pro_banner">
                <input type="hidden" name="pro_banner" value="" id="pro_banner">
                <? if(!empty($rs->pro_banner)){?>
                <a href="javascript:imgLib.openLib({dir_img:'product/banner/<?=$rs->pro_banner?>',width:756,height:180,method:'imgcrop',return_tag:'pro_banner',action:'imgcrop'});"><img src="<?=base_url_site()?>uploads/product/banner/<?=$rs->pro_banner?>" width="600px" /></a>
                <? } ?>
            </div></td>
    </tr>
    <tr>
        <td class="label"><?=lang('content_vn');?></td>
        <td><textarea class="wysiwyg" name="content_vn" id="content_vn"><?=$rs->content_vn?></textarea></td>
    </tr>
    <tr>
        <td class="label"><?=lang('content_en');?></td>
        <td><textarea class="wysiwyg" name="content_en" id="content_en"><?=$rs->content_en?></textarea></td>
    </tr>
    <tr>
        <td class="label" style="width: 150px;"><?=lang('keywords')?></td>
        <td><textarea id="summary_vn" class="w710" name="summary_vn"><?=$rs->summary_vn?></textarea>
    </tr>
    <tr>
        <td class="label" style="width: 150px;"><?=lang('keywords_en')?></td>
        <td><textarea id="summary_en" class="w710" name="summary_en"><?=$rs->summary_en?></textarea>
    </tr>
    <tr>
        <td class="label" style="width: 150px;">Thứ tự</td>
        <td><input type="text" name="nb_order" id="nb_order" class="w350" value="<?=$rs->nb_order?>"></td>
    </tr>
    <tr>
        <td class="label"><?=lang('status')?></td>
        <td><input type="checkbox" name="bl_active" id="bl_active" <?php if($rs->bl_active==1) echo 'checked'; ?>  value="1"></td>
    </tr>
    <tr>
        <td colspan="2" align="center"><input type="submit" name="bt_submit" value="" class="capnhat"></td>
    </tr>
</table>
<?=form_close()?>
<script type="text/javascript">
mkselected('catid','<?php echo $rs->catid?>');
$(document).ready(function(){
	$("#product").validate({
        rules: {
            catid: "required",
            name_vn :"required",
        },
        messages: {
			catid: "Vui lòng chọn danh mục",
			name_vn:"Vui lòng nhập tiêu đề vào.",
        }
    });
	
	$.validator.addMethod('validateImage', function() {
		var test_value = $("#lb_image").val();
		if(test_value=='') return false;
        var extension = test_value.split('.').pop().toLowerCase();

        if( $.inArray(extension, ['png', 'gif' ,'jpeg', 'jpg']) == -1 ){
            return false;
        }
        else{
            return true;
        }
	});
});
</script> 